<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'edit';
$return=array();
$tabs=array(
	array('op'=>'edit','title'=>'数据搬移'),
	array('op'=>'log','title'=>'操作日志'),
);
if($_RQ['op']=='edit'){
	$basic=$this->plugin_setting('basic');
	if(!$basic['host'] || !$basic['username'] || !$basic['password'] || !$basic['port'] || !$basic['database'] || !$basic['tablepre']){
		exi('请选配置好参数！','error');
	}
	$return=array();
	$htmls=array(
		'type'=>'edit',
		'post'=>'post',
		'tabs'=>$tabs,
		'edit'=>array(
			array('type'=>'tip','title'=>'【温馨提示】：搬移数据会直接跳过本站点已有的数据，最好用全新站点来搬移！'),
			array('type'=>'radio','title'=>'搬移数据类型','name'=>'type','options'=>'types'),
			array('type'=>'select','title'=>'源站点公众号','name'=>'funiacid','options'=>'funiacids'),
		)
	);
	//$config=plugin('jy_job2dao')->plugin_setting('basic');
	//require_once ROOT_D.'/addons/jy_job2dao/todb.php';
	//$todb=new todb($config);
	$return['funiacids']=$this->model('api')->getfuniacids();
	$return['types']=array('搬移企业数据','搬移企业账号数据','搬移职位数据','搬移粉丝数据','搬移会员数据','搬移简历数据');
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='post'){
	$postdata=get_postdata();
	if(!$postdata['funiacid']){
		exi('请选择源站点公众号','error');
	}
	$this->model('api')->daoru($postdata);
	exi('操作成功！');
}
if($_RQ['op']=='uppage'){
	if(!$_RQ['funiacid']){
		exi('请选择源站点公众号','error');
	}
	$page=$_RQ['page'];
	if(!$_RQ['type']){
		$this->model('api')->uptype0($_RQ['funiacid'],$page);
	}elseif($_RQ['type']==1){
		$this->model('api')->uptype1($_RQ['funiacid'],$page);
	}elseif($_RQ['type']==2){
		$this->model('api')->uptype2($_RQ['funiacid'],$page);
	}elseif($_RQ['type']==3){
		$this->model('api')->uptype3($_RQ['funiacid'],$page);
	}elseif($_RQ['type']==4){
		$this->model('api')->uptype4($_RQ['funiacid'],$page);
	}elseif($_RQ['type']==5){
		$this->model('api')->uptype5($_RQ['funiacid'],$page);
	}
	exi('操作成功！','','/updata/');
}
if($_RQ['op']=='log'){
	$return['params']=array();
	$params=array('type'=>1,'uniacid'=>$_SESSION['uniacid']);
	if(isset($_RQ['type']) && $_RQ['type']!=100){
		$params['type']=intval($_RQ['type']);
		$return['params']['type']=intval($_RQ['type']);
	}
	$pindex = max(1, intval($_RQ['page']));
	if($_RQ['psize']){
		$_SESSION['psize']=$_RQ['psize'];
	}
	$psize = $_SESSION['psize']?:20;
	$list=pdo_getslice('jy_job2dao_log',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as $k=>&$item){
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','total'=>$total,'psize'=>$psize,'edit'=>false,'del_one'=>false,'delall'=>false,'list'=>array(
			array('name'=>'id','title'=>'ID','type'=>'string'),
			array('name'=>'type','title'=>'操作类型','type'=>'radio','options'=>'types'),
			array('name'=>'funiacid','title'=>'源站点公众号ID','type'=>'string'),
			array('name'=>'funiacidtitle','title'=>'源站点公众号','type'=>'string'),
			array('name'=>'createtime','title'=>'预约时间','type'=>'time'),
		)),
		'search'=>array(
			array('type'=>'radio','width'=>15,'name'=>'type','options'=>'up1types','title'=>'类型'),
		),
	);
	$return['types']=array('搬移企业数据','搬移企业账号数据','搬移职位数据','搬移粉丝数据','搬移会员数据','搬移简历数据');
	$return['htmls']=$htmls;	
	exi($return);
}